package com.hm.PushCaseService.config.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

@Configuration
public class jedisPoolConfig {
    private static final Logger logger = LoggerFactory.getLogger(jedisPoolConfig.class);


    @Bean(name = {"jedisPool"})
    public JedisPool redisDataSource() {
        logger.warn("=======》redisDataSource初始化了《=======");
        //测试环境
        String host= "172.26.2.18";
        //正式环境
        //String host= "172.26.1.16";
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        // 最大空闲数
        jedisPoolConfig.setMaxIdle(10);
        // 连接池的最大数据库连接数
        jedisPoolConfig.setMaxTotal(100);
        //资源池确保的最少空闲连接数
        jedisPoolConfig.setMinIdle(1);
        //是否开启空闲资源检测
        jedisPoolConfig.setTestWhileIdle(true);
        return new JedisPool(jedisPoolConfig, host, 6379, 2000, "Szcg@redis2023_root%#");
    }

}
